#CRUD操作
#Creat
insert into test_biao(name) values ('name_1'), ('name_2')

#Retrieve
select * from test_biao # 获取所有记录

select * from test_biao where name = "name_1" and id = 1 or id = 2 # 条件查询

select * from test_biao where name like "n%" #模糊匹配

select * from test_biao where name like "n%" limit 3 #限制返回条数

select distinct name, creat_time from test_biao # 过滤重复值

select name, creat_time from test_biao order by creat_time # 升序(默认)

select id creat_time from test_biao order by creat_time desc # 降序

select count(*) from test_biao order by creat_time desc # 获取查询结果条数

# Update
update test_biao set name = 'name_0' where id = 1

#Delete

delete from test_biao where name = 'name_0'

#集合操作
#并集
select name from test_biao where name is not null
union
select name from test_biao1 where name is not null

#交集
select A.name from
(select name from test_biao where name is not null) as A
join
(select name from test_biao1 where name is not null) as B
on A.name = B.name

#差集
#A对B的差集
select A.name from
(select name from test_biao where name is not null) as A
left join
(select name from test_biao1 where name is not null) as B
on A.name = B.name
where B.name is null

# B对A的差集
select B.name from
(select name from test_biao where name is not null) as A
right join
(select name from test_biao1 where name is not null) as B
on A.name = B.name
where A.name is null

#补集
select A.name from
(select name from test_biao where name is not null) as A
left join
(select name from test_biao1 where name is not null) as B
on A.name = B.name
where B.name is null

union

select B.name from
(select name from test_biao where name is not null) as A
right join
(select name from test_biao1 where name is not null) as B
on A.name = B.name
where A.name is null